hysop.backend.device.opencl.opencl_mempool module

class hysop.backend.device.opencl.opencl_mempool.OpenClMemoryPool(name, allocator, max_alloc_bytes=None, mantissa_bits=4, verbose=None, **kwds)[source]

Bases: MemoryPool, OpenClAllocator

Builds a MemoryPool from an allocator. Provides an allocator like interface.

Parameters:
  • name (str) – the name of this allocator for logging purposes

  • allocator (hysop.core.memory.AllocatorBase) – allocator used by this memory pool, must be an immediate allocator.

  • verbose (bool) – turn on or off allocator messages (defaults to hysop verbosity configuration)

  • max_alloc_bytes (int) –

    maximum number of bytes this pool will try to allocate before raising a MemoryError. default value is:

    -80% of physical host memory if allocator is a HostAllocator. -None (no limit) if allocator is a DeviceAllocator

  • mantissa_bits (int) – subdivisions bits of power of two allocations. higher values means more bins (less memory waste) but less buffer reuse.

Notes

An allocator that fails to allocate memory should raise a MemoryError to expect the pool to work correctly.

Some allocators may fail to raise a MemoryError when there is no more memory left and will just trigger a SIGKILL from operating system or deadlock instead. To avoid such situations, put an artificial software allocation imit trough the max_alloc_bytes parameter. Exceeding this allocation limit will throw a proper MemoryError.

Examples:

*Host allocation on ubuntu 16.04 => SIGKILL *OpenCl AMD mesa open source driver on ubuntu 16.04 => deadlock *OpenCl Nvidia 375.20 driver on ubuntu 16.04 => work as expected

prefix()[source]

Prefix for logs